% Konwersja list zadan 
% ### - glowne parametry do ustawiania
%%%% Pliki We/wy%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Scale=2;                                        %### skala przeskalowanej mapy
dT=10;						%### co ile wrzucać agentów
InputListName='lista04_b.txt';                  %### Plik we (z paramertem _b sa
                                                %    prawidlowo formatowane)
OutputListName=[InputListName(1:end-6) 'x' int2str(Scale) 't' int2str(dT) '.dat'] %Plik wy


% InputList=importdata(InputListName);
InputList=dlmread(InputListName);
InputList=InputList(:,1:4);
InputList=InputList*Scale;  

% zamiana wspolrzednych X i Y : 
% W naszym programie wczytywane są Y X
% A na liście są Y X
% zamiana:
% [1 2 3 4] -> [2 1 4 3]
SwapTMP=InputList;
InputList(:,1)=SwapTMP(:,2);
InputList(:,2)=SwapTMP(:,1);
InputList(:,3)=SwapTMP(:,4);
InputList(:,4)=SwapTMP(:,3);


%%%%% Dodawane dane %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
T=[1:100]'*dT ;                         %### czasy dodawania robotow
%A=ones(length(InputList),2)*4;        	%### A - punkty startu
A=[ones(length(InputList),1)*9 ones(length(InputList),1)*4 ];
%D=A;                          		%### D - punkty wyjazdu
D=[ones(length(InputList),1)*3 ones(length(InputList),1)*5 ];

%% wyjscia w rogach 


%Otrzymujemy wyjsciowa liste
OutputList=[T A InputList D];     

%% Zapis danych
fid = fopen(OutputListName,'wt');
fprintf(fid, ['# ' OutputListName '\n']);
fprintf(fid, [int2str(length(InputList)) '\n']);
for ii = 1:size(OutputList,1)
    fprintf(fid,'%g ',OutputList(ii,:));
    fprintf(fid,'\n');
end
fclose(fid);
